Imports CapaDeDatos
Public Class nChequesPropios
    Private ChequePropio As CapaDeDatos.dChequesPropios = New CapaDeDatos.dChequesPropios
    Private Banco As CapaDeDatos.dBanco = New CapaDeDatos.dBanco
    Private Cuentas As CapaDeDatos.dCuenta = New CapaDeDatos.dCuenta
    Private Chequera As CapaDeDatos.dChequera = New CapaDeDatos.dChequera
    Private Alerta As CapaDeDatos.dAlerta = New CapaDeDatos.dAlerta


    Public Function InsertarChequePropio(ByVal CodigoCheque As String, _
                                        ByVal CodigoChequera As String, _
                                        ByVal CodigoProveedor As String, _
                                        ByVal Importe As String, _
                                        ByVal FechaVence As String, _
                                        ByVal FechaEmision As String, _
                                        ByVal Observacion As String, _
                                        ByVal ANombreDe As String, _
                                        ByVal Estado As String) As Boolean
        If FechaVence <> "" Then
            Alerta.Insertar("VENCIMIENTO - CHEQUE PROPIOS", ("Cheque Emitido para " & ANombreDe.ToUpper & "- Por la suma de :" & Importe).ToString, CDate(FechaVence).Date, CDate(FechaVence).Date, "", "", "")
        End If
        Return ChequePropio.Insertar(CodigoCheque _
                                    , CodigoChequera _
                                    , CodigoProveedor _
                                    , Importe _
                                    , FechaVence _
                                    , FechaEmision _
                                    , Observacion _
                                    , ANombreDe _
                                    , Estado)




    End Function
    Public Function ExisteCheque(ByVal IdCheque As String, _
                                    ByVal CodigoChequera As String, _
                                    ByVal Importe As String, _
                                    ByVal FechaVence As String, _
                                    ByVal FechaVenceMIN As String, _
                                    ByVal FechaVenceMAX As String, _
                                    ByVal FechaEmision As String, _
                                    ByVal FechaEmisionMIN As String, _
                                    ByVal FechaEmisionMAX As String, _
                                    ByVal Observacion As String) As Boolean
        Return ChequePropio.BuscarFiltrado(IdCheque, _
                                    CodigoChequera, _
                                    Importe, _
                                    FechaVence, _
                                    FechaVenceMIN, _
                                    FechaVenceMAX, _
                                    FechaEmision, _
                                    FechaEmisionMIN, _
                                    FechaEmisionMAX, _
                                    Observacion).Tables(0).Rows.Count <> 0
    End Function
    Public Function EliminarChequePropio(ByVal CodigoChequePropio As String, ByVal Observaciones As String) As Boolean
        Return ChequePropio.Eliminar(CodigoChequePropio, Observaciones)
    End Function
    Public Function ObtenerNumero(ByVal CodigoChequera As String) As Integer
        Dim dts As DataSet = ChequePropio.ObtenerNumero(CodigoChequera)
        If dts.Tables(0).Rows.Count() > 0 Then
            Return CInt(dts.Tables(0).Rows(0)(0).ToString()) + 1
        Else
            Return Int(Chequera.BuscarFiltrado(Int(CodigoChequera), 0, 0, 0).Tables(0).Rows(0)("Comienzo").ToString())
        End If
    End Function
    Public Function ModificarChequePropio(ByVal IdCheque As String, _
                                ByVal CodigoChequera As String, _
                                ByVal Importe As String, _
                                ByVal FechaVence As String, _
                                ByVal FechaEmision As String, _
                                ByVal Observacion As String) As Boolean
        Return ChequePropio.Modificar(IdCheque, _
                                        CodigoChequera, _
                                        Importe, _
                                        FechaVence, _
                                        FechaEmision, _
                                        Observacion)
    End Function
    Public Function ListarChequePropios(ByVal IdCheque As String, _
                                    ByVal CodigoChequera As String, _
                                    ByVal Importe As String, _
                                    ByVal FechaVence As String, _
                                    ByVal FechaVenceMIN As String, _
                                    ByVal FechaVenceMAX As String, _
                                    ByVal FechaEmision As String, _
                                    ByVal FechaEmisionMIN As String, _
                                    ByVal FechaEmisionMAX As String, _
                                    ByVal Observacion As String) As DataSet
        Return ChequePropio.BuscarFiltrado(IdCheque, _
                                    CodigoChequera, _
                                    Importe, _
                                    FechaVence, _
                                    FechaVenceMIN, _
                                    FechaVenceMAX, _
                                    FechaEmision, _
                                    FechaEmisionMIN, _
                                    FechaEmisionMAX, _
                                    Observacion)
    End Function
    'Public Function ListarTodos(ByVal IdCheque As String, _
    '                                ByVal CodigoChequera As String, _
    '                                ByVal Importe As String, _
    '                                ByVal FechaVence As String, _
    '                                ByVal FechaVenceMIN As String, _
    '                                ByVal FechaVenceMAX As String, _
    '                                ByVal FechaEmision As String, _
    '                                ByVal FechaEmisionMIN As String, _
    '                                ByVal FechaEmisionMAX As String, _
    '                                ByVal Observacion As String) As DataSet
    '    Dim dtsPrincipal As DataSet
    '    dtsPrincipal = ChequePropio.BuscarFiltrado(IdCheque, _
    '                                CodigoChequera, _
    '                                Importe, _
    '                                FechaVence, _
    '                                FechaVenceMIN, _
    '                                FechaVenceMAX, _
    '                                FechaEmision, _
    '                                FechaEmisionMIN, _
    '                                FechaEmisionMAX, _
    '                                Observacion)
    '    dtsPrincipal.Tables(0).Columns.Add("Denominacion")
    '    dtsPrincipal.Tables(0).Columns.Add("NumeroCuenta")
    '    Dim i As Integer
    '    For i = 0 To dtsPrincipal.Tables(0).Rows.Count - 1
    '        Try
    '            dtsPrincipal.Tables(0).Rows(i)("Denominacion") = Banco.BuscarFiltradoNom(Cuentas.DarBanco(Int(dtsPrincipal.Tables(0).Rows(i)("CodigoCuenta").ToString()), 0), "").Tables(0).Rows(0)("Denominacion").ToString()
    '        Catch ex As Exception
    '            dtsPrincipal.Tables(0).Rows(i)("Denominacion") = "Error, Banco no Encontrado"
    '        End Try
    '        Try
    '            dtsPrincipal.Tables(0).Rows(i)("NumeroCuenta") = Cuentas.BuscarFiltrado(Int(dtsPrincipal.Tables(0).Rows(i)("CodigoCuenta").ToString()), "", 0, "").Tables(0).Rows(0)("NumeroCuenta").ToString()
    '        Catch ex As Exception
    '            dtsPrincipal.Tables(0).Rows(i)("NumeroCuenta") = "Error, Cuenta no Encontrada"
    '        End Try
    '    Next
    '    Return dtsPrincipal
    'End Function
End Class
